package com.gxa.service.impl;

import com.gxa.mapper.SupplierMapper;
import com.gxa.pojo.CustomerType;
import com.gxa.pojo.Supplier;
import com.gxa.service.SupplierService;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
@Service("SupplierService")
public class SupplierServiceImpl implements SupplierService {

    @Autowired
    SupplierMapper supplierMapper;

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = {Throwable.class})
    public int insertSelective(Map map) {
        return supplierMapper.insertSelective(map);
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = {Throwable.class})
    public int deleteByPrimaryKey(Integer id) {
        return supplierMapper.deleteByPrimaryKey(id);
    }

    // 批量删除
    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = {Throwable.class})
    public int deleteBatch(List<Integer> list) {
        return supplierMapper.deleteBatch(list);
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED,rollbackFor = {Throwable.class})
    public int updateByPrimaryKeySelective(Map map) {
        return supplierMapper.updateByPrimaryKeySelective(map);
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    public Integer findAllSupplier() {
        return supplierMapper.findAllSupplier();
    }

    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    public List<Supplier> findAllSupplierByPage(Integer start, Integer pageSize) {
        return supplierMapper.findAllSupplierByPage(start,pageSize);
    }

    //多参数模糊查询
    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    public List<Map<String, Object>> findBySelect(Map<String, Object> map) {
        return supplierMapper.findBySelect(map);
    }

    // 计算查询条数
    @Override
    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.SUPPORTS,rollbackFor = {Throwable.class})
    public Integer countFindSupplier(Map<String, Object> map) {
        return supplierMapper.countFindSupplier(map);
    }


}
